package cn.shop.cloud.web.msg;


import cn.shop.cloud.common.CodeMsg;

import java.text.MessageFormat;

/**
 * @program: work
 * @ClassName MemberCodeMsg
 * @description: 关于会员的CodeMsg
 * @author: 李尧坤
 * @create: 2024−12-19 20:52
 * @Version 1.0
 **/

public class MemberCodeMsg extends CodeMsg {
    public MemberCodeMsg(Integer code, String msg) {
        super(code, msg);
    }

    public static final MemberCodeMsg OP_ERROR = new MemberCodeMsg(5000101,"非法操作");
    public static final MemberCodeMsg LOGIN_ERROR = new MemberCodeMsg(5000102,"账号或密码错误");
    public static final MemberCodeMsg PARAM_ERROR = new MemberCodeMsg(5000103,"参数校验：{0}");
    //jsr303
    //public static final MemberCodeMsg OP_ERROR = new MemberCodeMsg(5000104,"非法操作");

    public MemberCodeMsg fillArgs(Object... args){//可变长参数
        MemberCodeMsg codeMsg = new MemberCodeMsg(this.getCode(),this.getMsg());

        codeMsg.setMsg(MessageFormat.format(codeMsg.getMsg(),args));

        return codeMsg;
    }

    public static void main(String[] args) {
        String str = "无心今年{0}岁";
        
        String newString =  MessageFormat.format(str,18);

        System.out.println(newString);
    }
}
